package com.dms.wuziqi.mapper;

import com.dms.wuziqi.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from userInfo where user_id=#{userId}")
    @Results({
            @Result(column = "user_id",property = "userId"),
            @Result(column = "user_id",property = "loans",many = @Many(select = "com.dms.wuziqi.mapper.LoanMapper.getAllLoanByUserId")),
            @Result(column = "user_realname",property = "userRealName"),
            @Result(column = "risk_level",property = "riskLevel"),
            @Result(column = "user_cardId",property = "userCardId"),
            @Result(column = "user_phone",property = "userPhone")

    })
    User findUserById(int userId);
    @Select("SELECT * from userInfo where user_name=#{userName} and user_pwd=#{userPwd}")
    @Results({
            @Result(column= "user_id",property = "userId"),
            @Result(column = "user_name",property = "userName"),
            @Result(column = "user_pwd",property = "userPwd"),
    })
    User findUserByNameAndPwd(String userName,String userPwd);
    @Insert("INSERT INTO userInfo (user_name,user_pwd) values (#{userName},#{userPwd})")
    void insertUser(String userName,String userPwd);

}
